#ifndef __OPENCL_HELPER_H
#define __OPENCL_HELPER_H

#include <cstdio>
#include <iostream>
#include <fstream>
#include <memory>
#include <vector>
#include "opencl_wrapper.h"
#include "utils.h"
#include <cstring>

namespace mslite {

#define CHECK(cl_status, err_info) \
if (cl_status != CL_SUCCESS) \
{ \
    std::cout << err_info << ": " << cl_status << std::endl; \
    return EXIT_FAILURE; \
}


void loadOpenCL(void);
void printfCallback(const char *buffer, size_t length, size_t final, void *user_data);
int printCLInfo(void);
int createCLEnv(int targetPlatform, cl_device_id &device, 
                cl_context &context, cl_command_queue& commandQueue);
int compileKernel(const std::string srcCode, const size_t srcSize, const std::string kernelName,
                  const cl_context context, const cl_device_id device, cl_program &program, cl_kernel& kernel);
cl_mem createImage2d(cl_context context, cl_channel_type type, int width, int height, void* data, cl_int *status);
double profileTime(cl_event profEvent, bool log=true);
int releaseEnv(cl_context context, cl_command_queue commandQueue);

}

#endif
